home *** CD-ROM | disk | FTP | other *** search
- /*****************************************************************************/
- /* (C) 1993,1994 R. NADE - M. GRANDCHAMP - All Rights Reserved */
- /*****************************************************************************/
- /* This source-code is NOT public domain nor Freeware, this is part of */
- /* 'The C Programming Package' which is Shareware. */
- /* If you use this code, please register and get a free Full-VGA version */
- /*****************************************************************************/
- /*----------------*
- * CPPLMEN9.C *
- * Menu manager9 *
- * Configuration *
- * environment *
- *----------------*/
-
- /* Included Files */
- # include <stdio.h>
- # include <io.h>
- # include <dos.h>
- # include <fcntl.h>
- # include <bios.h>
- # include <stdlib.h>
- # include <conio.h>
-
- /* Global Variables */
- extern int bm,i,j,k,l,m,n,t,x,x1,x2,xm,y,y1,y2,ym,z,menu0,menu9;
- extern int colour1,colour2,colour3,colour4,colour5,soundvar,return1;
- extern unsigned char c0,c1,trashcan[];
-
- /*----------------------*
- * CHOICE DISPLAY HELP9 *
- *----------------------*/
- void choice_display_help9()
- {
- /* We display the help that concerns the line on */
- /* which is the menu cursor (in red). */
- if(menu9==1){
- /* */
- display_help("CONFIGUR",90,2,1); restore_help_screen();
- }
- if(menu9==2){
- /* */
- display_help("CONFIGUR",91,3,1); restore_help_screen();
- }
- if(menu9==3){
- /* */
- display_help("CONFIGUR",92,4,1); restore_help_screen();
- }
- if(menu9==4){
- /* */
- display_help("CONFIGUR",93,5,1); restore_help_screen();
- }
- if(menu9==5){
- /* */
- display_help("CONFIGUR",94,6,1); restore_help_screen();
- }
- if(menu9==6){
- /* */
- display_help("CONFIGUR",95,7,1); restore_help_screen();
- }
- if(menu9==7){
- /* available */
- display_help("CONFIGUR",96,8,1); restore_help_screen();
- }
- if(menu9==8){
- /* */
- display_help("CONFIGUR",97,9,1); restore_help_screen();
- }
- if(menu9==9){
- /* */
- display_help("CONFIGUR",98,10,1); restore_help_screen();
- }
- if(menu9==10){
- /* quit to DOS */
- display_help("CONFIGUR",99,11,1); restore_help_screen();
- }
- }
- /*----------------*
- * GET THE MOUSE9 *
- *----------------*/
- int get_the_mouse9()
- {
- /* If we choose with the mouse */
- /* Only available for menu 1 */
- if((ym>0)&&(ym<3)){
- /* We clicked on the first line, certainly */
- /* To change of menu. */
- menu0=get_the_mouse0(); return(-2);
- }
- if((xm>62)&&(xm<79)){
- if(ym==3){
- /* Printer Choice */
- menu9=1; return(1);
- }
- if(ym==4){
- /* available */
- menu9=2; return(1);
- }
- if(ym==5){
- /* Choice of the 5 colours for the programs */
- menu9=3; return(1);
- }
- if(ym==6){
- /* Sound Yes / No */
- menu9=4; return(1);
- }
- if(ym==7){
- /* Access path to the files used by the programs /*
- menu9=5; return(1);
- }
- if(ym==8){
- /* Access path to the working file */
- menu9=6; return(1);
- }
- if(ym==9){
- /* Access path to the recording files */
- menu9=7; return(1);
- }
- if(ym==10){
- /* Re-create the file HELP.FIC from HELP.TXT */
- menu9=8; return(1);
- }
- if(ym==11){
- /* Display free space on the current drive */
- menu9=9; return(1);
- }
- if(ym==12){
- /* Display free memory */
- menu9=10; return(1);
- }
- }
- /* If we clicked outside the menu zone */
- /* we want to erase the menu and return to menu 0 */
- /* */
- menu0=0; return(-2);
- }
- /*---------------------*
- * GET KEYBOARD INPUT9 *
- *---------------------*/
- int get_keyboard_input9()
- {
- /* Standard keyboard keys */
- if(c1==27){
- /* <Esc> we want to go back to menu0 */
- menu0=0; return(-2);
- }
- if(c1==13){
- /* <Enter> execute the command */
- return(1);
- }
- if((c1==80)||(c1==112)){
- /* <P> <p> Printer choice */
- menu9=1; return(1);
- }
- /* if((c1==86)||(c1==118)){ */
- /* <V> <v> Video choice */
- /* menu9=2; return(1);
- } */
- if((c1==67)||(c1==99)){
- /* <C> <c> Colours choice */
- menu9=3; return(1);
- }
- if((c1==83)||(c1==115)){
- /* <S> <s> Sound Yes/No */
- menu9=4; return(1);
- }
- if((c1==89)||(c1==121)){
- /* <Y> <y> Access path to the program files */
- menu9=5; return(1);
- }
- if((c1==87)||(c1==119)){
- /* <W> <w> Access path to the working files */
- menu9=6; return(1);
- }
- if((c1==82)||(c1==114)){
- /* <R> <r> Access path to the record directory */
- menu9=7; return(1);
- }
- if((c1==72)||(c1==104)){
- /* <H> <h> Help file. Redone from help.txt */
- menu9=8; return(1);
- }
- if((c1==70)||(c1==102)){
- /* <F> <f> Available on the current drive */
- menu9=9; return(1);
- }
- if((c1==77)||(c1==109)){
- /* <M> <m> */
- menu9=10; return(1);
- }
- return(0);
- }
- /*-----------------*
- * SPECIAL DECODE9 *
- *-----------------*/
- int special_decode9()
- {
- /* For the 2-bytes coded keys, this is the second byte */
- if(c1==59){
- /* Function key <F1> = help */
- return(22);
- }
- k=get_special_menu00();
- if(k>0) return(-2);
- if(c1==72){
- /* Up arrow */
- if(menu9>1) menu9--;
- else menu9=10;
- return(0);
- }
- if(c1==80){
- /* Down arrow */
- if(menu9<10) menu9++;
- else menu9=1;
- return(0);
- }
- return(0);
- }
- /*--------------*
- * MENU CHOICE9 *
- *--------------*/
- int menu_choice9()
- {
- /* We do nothing until a key is pressed */
- /* or we pressed a mouse button. */
- /* We use the 'l' return to test if the key pressed */
- /* or the mouse choice is one we are waiting for */
- /* else we wait a valid key */
- /* Notice that Up and Down arrows only move the cursor */
- /* and we need to confirm it with <Enter> */
- while(1){
- l=0;
- if(kbhit()){
- /* If we pressed a key */
- c1=getch();
- if(c1>0){
- t=get_keyboard_input9(); break;
- }
- else{
- /* Key coded on 2 bytes */
- c1=getch();
- t=special_decode9(); break;
- }
- }
- /* Else we test the mouse */
- get_mouse_state();
- if(bm==1){
- /* We pressed a mouse button */
- t=get_the_mouse9(); break;
- }
- }
- return(t);
- }
- /*--------------------*
- * DISPLAY MENU LINE9 *
- *--------------------*/
- void display_menu_line9()
- {
- /* First we display the chosen menu0 */
- textattr(colour5);
- gotoxy(66,1); cputs(" Config. ");
- /* Same thing for the selected line */
- if(menu9==1){
- gotoxy(63,3); cputs(" Printer ");
- }
- if(menu9==2){
- gotoxy(63,4); cputs(" ");
- }
- if(menu9==3){
- gotoxy(63,5); cputs(" Colours choice ");
- }
- if(menu9==4){
- gotoxy(63,6); cputs(" Sound = ");
- /* We display too if the sound is activated or not */
- gotoxy(72,6);
- if(soundvar==1) cputs(" yes ");
- else cputs(" no ");
- }
- if(menu9==5){
- gotoxy(63,7); cputs(" sYstem dir. ");
- }
- if(menu9==6){
- gotoxy(63,8); cputs(" Working dir. ");
- }
- if(menu9==7){
- gotoxy(63,9); cputs(" Recording dir. ");
- }
- if(menu9==8){
- gotoxy(63,10); cputs(" Help file ");
- }
- if(menu9==9){
- gotoxy(63,11); cputs(" Free disk space");
- }
- if(menu9==10){
- gotoxy(63,12); cputs(" avail. Memory ");
- }
- }
- /*----------------------*
- * DISPLAY KEY LETTER 9 *
- *----------------------*/
- void display_key_letter9()
- {
- textattr(116);
- gotoxy(64,3); cputs("P");
- gotoxy(64,4); cputs(" ");
- gotoxy(64,5); cputs("C");
- gotoxy(64,6); cputs("S");
- gotoxy(65,7); cputs("Y");
- gotoxy(64,8); cputs("W");
- gotoxy(64,9); cputs("R");
- gotoxy(64,10); cputs("H");
- gotoxy(64,11); cputs("F");
- gotoxy(71,12); cputs("M");
- /* We display if sound is activated or not */
- gotoxy(72,6);
- if(soundvar==1) cputs(" yes ");
- else cputs(" no ");
- }
- /*---------------*
- * DISPLAY MENU9 *
- *---------------*/
- void display_menu9()
- {
- /* To avoid the trace of the previous mouse position */
- /* we hide it during the display, */
- /* and show it when the line has been displayed. */
- hide_the_mouse(); textattr(colour2);
- gotoxy(61,2); cputs(" ┌────────────────┐ ");
- gotoxy(61,3); cputs(" │ Printer │ ");
- gotoxy(61,4); cputs(" │ │ ");
- gotoxy(61,5); cputs(" │ Colours choice │ ");
- gotoxy(61,6); cputs(" │ Sound = │ ");
- gotoxy(61,7); cputs(" │ sYstem dir. │ ");
- gotoxy(61,8); cputs(" │ Working dir. │ ");
- gotoxy(61,9); cputs(" │ Recording dir. │ ");
- gotoxy(61,10); cputs(" │ Help file │ ");
- gotoxy(61,11); cputs(" │ Free disk space│ ");
- gotoxy(61,12); cputs(" │ avail. Memory │ ");
- gotoxy(61,13); cputs(" └────────────────┘ ");
- display_key_letter9(); display_menu_line9();
- show_the_mouse();
- }
- /*----------------*
- * MENU MANAGER 9 *
- *----------------*/
- int menu_manager9()
- {
- restore_screen(); return1=0;
- while(1){
- display_menu9(); return1=menu_choice9();
- if(return1==-2) return(-2);
- if(return1==-1) return(-1);
- if(return1==22) choice_display_help9();
- display_menu9();
- if(return1==1){
- /* We execute the selected function */
- if(menu9==1){
- /* Printer choice */
- printer_choice();
- }
- if(menu9==2){
- /* available */
-
- }
- if(menu9==3){
- /* Colours choice */
- colour_choice();
- }
- if(menu9==4){
- /* Toggle sound */
- soundvar++;
- if(soundvar>1) soundvar=0;
- }
- if(menu9==5){
- /* Access path to the program and the config */
- define_the_system_directory();
- }
- if(menu9==6){
- /* define the working directory (users files) */
- define_the_work_directory();
- }
- if(menu9==7){
- /* define the recording path */
- define_recording_directory();
- }
- if(menu9==8){
- /* help file, change the file HELP.TXT to HELP.FIC */
- /* by cutting the RC and LF */
- create_on_line_help_file();
- }
- if(menu9==9){
- /* display the free space on the drive */
- display_free_space_on_disk();
- }
- if(menu9==10){
- /* display the free memory */
- display_free_memory();
- }
- }
- }
- }
- /* End of the Module *//*----------------*/
-